package com.briup.cms.service.impl;

import com.briup.cms.bean.Comment;
import com.briup.cms.dao.CommentMapper;
import com.briup.cms.exception.CustomerException;
import com.briup.cms.service.ICommentService;
import com.briup.cms.dao.extend.CommentExtendMapper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author Administrator
 * @version 1.0
 * @Description
 * @date 2021/7/17 21:07
 */

@Service
public class CommentServiceImpl implements ICommentService {
    @Resource
    private CommentMapper commentMapper;
    @Resource
    private CommentExtendMapper CommentExtendMapper;

    // 分页查询所有评论
    @Override
    public PageInfo<Comment> pageQuery(int pageNum, int pageSize, String keywords) {

        return null;
    }

    // 通过id删除评论
    @Transactional
    @Override
    public void deleteById(int id) throws CustomerException {

    }
    //保存更新
    @Transactional
    @Override
    public void saveOrUpdate(Comment comment) {
        if (comment.getCommentId() == null) {
            commentMapper.insert(comment);
        } else {
            commentMapper.updateByPrimaryKey(comment);
        }
    }
    // 批量删除评论
    @Transactional
    @Override
    public void batchDelete(int[] ids) throws CustomerException {

    }

    // 审核评论，状态：0-待审核，1-不通过，2-通过
    @Transactional
    @Override
    public void checkComment(int id, int status) throws CustomerException {

}


    public com.briup.cms.dao.extend.CommentExtendMapper getCommentExtendMapper() {
        return CommentExtendMapper;
    }

    public CommentMapper getCommentMapper() {
        return commentMapper;
    }

    public void setCommentMapper(CommentMapper commentMapper) {
        this.commentMapper = commentMapper;
    }
}
